pipeline {
    agent any
    tools {
        maven "apache-maven-3.6.3"
    }

    stages {
        stage('拉取代码') {
            agent none
            steps {
                git branch: 'master', credentialsId: 'git', url: 'https://gitee.com/ylxupup/mark-parent.git'
            }
        }

        stage('项目编译') {
            agent none
            steps {
                //编译  批量 指定配置文件                                                                     编译子模块
                sh "mvn -B -s /usr/share/maven/conf/settings.xml clean install -T 1C -Dmaven.test.skip=true -am"
            }
        }

        stage('部署') {
            agent none
            steps {
                sshPublisher failOnError: true,
                        publishers: [sshPublisherDesc(
                                configName: '8.134.217.134',
                                transfers: [sshTransfer(
                                        cleanRemote: false,
                                        excludes: '',
                                        execCommand: "cd /ylx/webApp && sh build-start.sh",
                                        execTimeout: 120000, flatten: false,
                                        makeEmptyDirs: false,
                                        noDefaultExcludes: false,
                                        patternSeparator: '[, ]+',
                                        remoteDirectory: "/ylx/webApp",
                                        remoteDirectorySDF: false,
                                        sourceFiles: "target/mark-app.jar",
                                        usePty: true)],
                                usePromotionTimestamp: false,
                                useWorkspaceInPromotion: false,
                                verbose: true
                        )]
            }
        }
    }
}